/* $Id:party.h $ */
/*
   Copyright (C) 2007 by Jurjen Stellingwerff <jurjen@stwerff.xs4all.nl>
   Part of the Moros Project http://moros.sourceforge.net/

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License version 3.
   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY.

   See the COPYING file for more details.
*/

#ifndef __PARTY_H
#define __PARTY_H

#include <string>
#include <map>
#include <list>
using namespace std;

#include "person.h"

#define loopPartyPlayers(r,v) loopMap((r)->listPlayers(),v,class person)

class party {
    string name;
    map<string,class person> players;
    int color;
    class army *capital;
public:
    party();

    // Field : name
    const string getName() const;
    void setName(const string v);

    // Field : players
    class person& getPlayers(const string v);
    map<string,class person>& listPlayers();
    void setPlayers(class person &v);
    void delPlayers(const string v);
    const bool isPlayers(const string v) const;

    // Field : color
    const int getColor() const;
    void setColor(const int v);

    // Field : capital
    class army& getCapital() const;
    void setCapital(class army &v);

    void save(class channel &ch);
    void load(class channel &ch);
    void xml(ofstream &f, int l=0, int r=0);
};

// Repository

#define loopPartys(v) loopMap(party_repo.listParty(),v,class party)

class partyRepository {
    map<string,party> partys;
public:
    class party& getParty(const string v);
    void setParty(class party& v);
    map<string,class party>& listParty();
    void delParty(const string v);
    const bool isParty(const string v) const;
    multimap<string, sigc::signal<void, class party& > > relations;
    bool load(class channel &ch);
    void save(class channel &ch);
};

extern partyRepository party_repo;

#endif // __PARTY_H
